package com.ren.mianshi.db;

import androidx.room.Room;

import com.ren.mianshi.App;


/**
 * @author renheng
 * @Description
 * @date 2020/8/21
 */

public class RoomManager {

    public final static String DB_NAME = "chat";


    private static final RoomManager ourInstance = new RoomManager();

    private AppDatabase appDatabase;

    public static RoomManager getInstance() {
        return ourInstance;
    }

    private RoomManager() {
    }

    public void init() {
        appDatabase = Room.databaseBuilder(App.getInstance(), AppDatabase.class, DB_NAME)
                .allowMainThreadQueries()
                .build();
    }

    public AppDatabase getAppDatabase() {
        if (appDatabase == null) {
            init();
        }
        return appDatabase;
    }


}
